<?php
namespace app\jok\logic;
use think\Request;
use think\Cache;
class jokCommonLogic
{
    public function _initialize(){
        
    }
    public function setToken($array){//生成token
        $header = Request::instance()->header();
        $platform = $header['platform'] ?? 'web';
        $keyname = strtoupper(encrytoken($array['id']));
        $keyValue = $array;
        Cache::set($platform . '_' . $keyname,$keyValue,3600);
        return $keyname;
    }
    public static function checkToken($token){
        $header = Request::instance()->header();
        $platform = $header['platform'] ?? 'web';
        $access_token = $header['authorization'] ?? '';
        $result = Cache::get($platform . '_' . $access_token);
        return $result;
    }
}